<?php
namespace app\post\model;
use app\admin\model\user\AdminOauth;
use app\admin\model\user\User;
use app\common\traits\ModelCurd;
use think\Model;
class CollectionModel extends Model
{
    use ModelCurd;
    protected $table = 'cp_portal_collection';
    protected $autoWriteTimestamp = true;

    public function getUserIdAttr($value,$data)
    {
        if($data['is_third']==1)
        {
            return User::where("id",$data['user_id'])->find();
        }elseif($data['is_third']==0){
            return AdminOauth::where("id",$data['user_id'])->find();
        }
    }


    public function article()
    {
        return $this->belongsTo(Post::class,"post_id");
    }

}